﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibData.Repository;

namespace NHibData.Service
{
    public class BaseService<T> : IBaseService<T> where T:BaseEntity
    {
        protected IRepository<T> MainRepository = RepositoryFactory.Create<T>();
        public T FindById(int id)
        {
            return MainRepository.FindById(id);
        }

        public void Save(T t)
        {
            MainRepository.SaveOrUpdate(t);
        }

        public void Update(T t)
        {
            MainRepository.Update(t);
        }

        public void Delete(T t)
        {
            MainRepository.Delete(t);
        }

        public IQueryable<T> AllItems()
        {
            return MainRepository.Linq;
        }
    }
}
